﻿using System.Linq;
using System.Web.Mvc;
using MCP.Model.Repositories.Interfaces;
using MoneyCounter.Models;

namespace MoneyCounter.Controllers
{
    public class UserMenuController : Controller
    {
	    private readonly IUnitOfWork unitOfWork;

		public UserMenuController(IUnitOfWork unitOfWork)
		{
			this.unitOfWork = unitOfWork;
		}

        public ActionResult UserMenu()
        {
	        var model = new UserMenuModel();
	        var checksCountResult = unitOfWork.CheckRepository.GetChecks();
			if (checksCountResult.Success)
			{
				model.ChecksCount = checksCountResult.Result.Count();
			}
			else
			{
				model.Messages = checksCountResult.Messages;
			}

            return View(model);
        }
    }
}